#ifndef __KEY_H__
#define __KEY_H__

#include "main.h"

// 定义按键
#define KEY0_PIN GPIO_PIN_0
#define KEY1_PIN GPIO_PIN_1
#define KEY2_PIN GPIO_PIN_2
#define KEY3_PIN GPIO_PIN_3
#define KEY0_PORT GPIOA
#define KEY1_PORT GPIOA
#define KEY2_PORT GPIOA
#define KEY3_PORT GPIOA

// 读取按键
#define KEY0_Read HAL_GPIO_ReadPin(KEY0_PORT,KEY0_PIN)
#define KEY1_Read HAL_GPIO_ReadPin(KEY1_PORT,KEY1_PIN)
#define KEY2_Read HAL_GPIO_ReadPin(KEY2_PORT,KEY2_PIN)
#define KEY3_Read HAL_GPIO_ReadPin(KEY3_PORT,KEY3_PIN)

// 按键返回键值
#define KEY0_PRES 1
#define KEY1_PRES 2
#define KEY2_PRES 3
#define KEY3_PRES 4

// 按键消抖时间
#define KEY_SCAN_TIME 10
// 延时函数重定义方便移植
#define key_delay HAL_Delay
// 函数声明
void Key_Init(void);
uint8_t Key_GetNum(void);//按键读取
uint8_t Key_Scan(void);
#endif
